<?php
/**
*
* ajax异步查询订单是否完成
* 
**/
require_once "../lib/WxPay.Api.php";
require_once 'log.php';
require_once "WxPay.Config.php";

//初始化日志
$logHandler= new CLogFileHandler("../logs/".date('Y-m-d').'.log');
$log = Log::Init($logHandler, 15);

$v = $_POST["out_trade_no"];
if(isset($v) && $v != ""){
    $out_trade_no = $v;
    $config = new WxPayConfig();
    $input = new WxPayOrderQuery();
    $input->SetOut_trade_no($out_trade_no);
    $input->SetSub_mch_id($config->GetSubMchId());//子商户号 by vbyzc
    $result = WxPayApi::orderQuery($config, $input);
    if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){//返回查询结果
        echo $result['trade_state'];
    }else{
        echo "FAIL";
    }
}
?>